﻿using Abp.Application.Services;
using Abp.Application.Services.Dto;
using Abp.AspNetCore.Mvc.Authorization;
using AbpZeroTemplate.Common;
using AbpZeroTemplate.Common.Dto;
using AbpZeroTemplate.Editions.Dto;
using AbpZeroTemplate.Web.Controllers;
using AbpZeroTemplate.Web.Swagger;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;

namespace AbpZeroTemplate.Api.Admin.Controllers
{
    /// <summary>帐号相关
    /// </summary>
    [Area("Admin")]
    [Route("Admin/CommonLookup/[action]")]
    [ApiName("Admin")]
    [RemoteService]
    [AbpMvcAuthorize]
    public class CommonLookupController : AbpZeroTemplateControllerBase
    {
        private readonly ICommonLookupAppService _commonLookupAppService;
        /// <summary>
        /// </summary>
        public CommonLookupController(ICommonLookupAppService commonLookupAppService)
        {
            _commonLookupAppService = commonLookupAppService;
        }

        /// <summary>获取版本数据
        /// </summary>
        [HttpGet]
        public async Task<ListResultDto<SubscribableEditionComboboxItemDto>> GetEditionsForCombobox()
        {
            return await _commonLookupAppService.GetEditionsForCombobox();
        }

        /// <summary>查询用户
        /// </summary>
        [HttpPost]
        public async Task<PagedResultDto<NameValueDto>> FindUsers([FromBody]FindUsersInput input)
        {
            return await _commonLookupAppService.FindUsers(input);
        }

        /// <summary>获取默认版本名称
        /// </summary>
        [HttpGet]
        public GetDefaultEditionNameOutput GetDefaultEditionName()
        {
            return _commonLookupAppService.GetDefaultEditionName();
        }
    }
}
